package com.risetek.tft.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Where;

/**
 * TDict entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_sys_dict")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class TDict extends BaseEntity2 implements java.io.Serializable {

	// Fields

	private TDict TDict;
	private String skey;
	private String message;
	private String type;
	private String scort;
	private Integer nlevel;
	private Set<TDict> TDicts = new HashSet<TDict>(0);
	private Set<TDict> TUseTypes = new HashSet<TDict>(0);
	private Set<TDict> TPriceTypes = new HashSet<TDict>(0);
	private Set<TDict> TTimeTypes = new HashSet<TDict>(0);
	private Set<TDict> TVideoTypes = new HashSet<TDict>(0);
	private Set<TDict> TVideoTimeTypes = new HashSet<TDict>(0);

	// Constructors

	/** default constructor */
	public TDict() {
	}

	/** full constructor */
	public TDict(TDict TDict, String skey, String message, String type,
			Set<TDict> TDicts) {
		this.TDict = TDict;
		this.skey = skey;
		this.message = message;
		this.type = type;
		this.TDicts = TDicts;
	}

	 

	public String getScort() {
		return scort;
	}

	public void setScort(String scort) {
		this.scort = scort;
	}

	public Integer getNlevel() {
		return nlevel;
	}

	public void setNlevel(Integer nlevel) {
		this.nlevel = nlevel;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pid")
	public TDict getTDict() {
		return this.TDict;
	}

	public void setTDict(TDict TDict) {
		this.TDict = TDict;
	}

	@Column(name = "skey", length = 50)
	public String getSkey() {
		return this.skey;
	}

	public void setSkey(String skey) {
		this.skey = skey;
	}

	@Column(name = "message", length = 100)
	public String getMessage() {
		return this.message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	@Column(name = "type", length = 30)
	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TDict")
	@OrderBy("id")
	public Set<TDict> getTDicts() {
		return this.TDicts;
	}

	public void setTDicts(Set<TDict> TDicts) {
		this.TDicts = TDicts;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TDict")
	@OrderBy("id")
	@Where(clause="TYPE='use_type'")
	public Set<TDict> getTUseTypes() {
		return TUseTypes;
	}

	public void setTUseTypes(Set<TDict> tUseTypes) {
		TUseTypes = tUseTypes;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TDict")
	@OrderBy("id")
	@Where(clause="type='price_type'")
	public Set<TDict> getTPriceTypes() {
		return TPriceTypes;
	}

	public void setTPriceTypes(Set<TDict> tPriceTypes) {
		TPriceTypes = tPriceTypes;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TDict")
	@OrderBy("id")
	@Where(clause="TYPE='time_type'")
	public Set<TDict> getTTimeTypes() {
		return TTimeTypes;
	}

	public void setTTimeTypes(Set<TDict> tTimeTypes) {
		TTimeTypes = tTimeTypes;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TDict")
	@OrderBy("id")
	@Where(clause="TYPE='video_use_type'")
	public Set<TDict> getTVideoTypes() {
		return TVideoTypes;
	}

	public void setTVideoTypes(Set<TDict> tVideoTypes) {
		TVideoTypes = tVideoTypes;
	}
	
	 
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TDict")
	@OrderBy("id")
	@Where(clause="TYPE='video_use_time_type'")
	public Set<TDict> getTVideoTimeTypes() {
		return TVideoTimeTypes;
	}

	public void setTVideoTimeTypes(Set<TDict> tVideoTimeTypes) {
		TVideoTimeTypes = tVideoTimeTypes;
	}

	@Transient
	public boolean isLeaf() {
		return this.TDicts.isEmpty();
	}
}